<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>隐藏与显示</title>
</head>
<body>
      <div id="box" style="display: block">aaaa</div>
      <input type="button" id="btn" value="隐藏">
      <input type="button" id="btn2" value="显示">


        <script>
            var btnobj = document.getElementById('btn');
            var btnobj2 = document.getElementById('btn2');
            var boxobj = document.getElementById('box');


            btnobj.onclick = function () {
                if(boxobj.style.display=='block'){
                    boxobj.style.display = 'none'
                }
            }

           btnobj2.onclick = function () {
               if(boxobj.style.display =='none'){
                   boxobj.style.display = 'block'
               }
           }
        </script>
</body>
</html>